#include "stdafx.h"
#include "Cursor.h"

Cursor::Cursor()
{
	
}

Cursor::~Cursor()
{

}

bool Cursor::Init(const std::string& aFileName)
{
	myPosition = Graphics::Engine::GetInstance()->GetResolution().GetCenter();
	return mySprite.Init(aFileName);
}

void Cursor::Update()
{
	Vector2f mouseDelta(0,0);
	WMInput::WM_InputWrapper::GetInstance()->GetMouseDeltaPosition(mouseDelta.x, mouseDelta.y);
	myPosition += mouseDelta;
	ClipCursor();

	mySprite.SetPosition(Graphics::Engine::GetInstance()->GetResolution().ConvertToCursorPos(myPosition));
}

void Cursor::ClipCursor()
{
	const Vector2f& res = Graphics::Engine::GetInstance()->GetResolution().GetBaseResolution();
	if(myPosition.x > res.x)
	{
		myPosition.x = res.x;
	}
	else if(myPosition.x < 0)
	{
		myPosition.x = 0;
	}

	if(myPosition.y > res.y)
	{
		myPosition.y = res.y;
	}
	else if(myPosition.y < 0)
	{
		myPosition.y = 0;
	}
}